package work;
import java.text.MessageFormat;

import model.user;
import model.database;

public class UserOpe {
	public void addUser(user one)
	{
		database db = new database(
				"jdbc:mysql://localhost/gazi?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT&useSSL=false",
				"root",
				"123456");
		String[] keys = {"phone", "cookie", "timestamp"};
		String[] values = {one.getPhone(), one.getCookie(), one.getTimestamp()};
		int res = db.insert("user", keys, values);
	}
	public boolean isHaveUser(user one)
	{
		database db = new database(
				"jdbc:mysql://localhost/gazi?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT&useSSL=false",
				"root",
				"123456");
		String sql = MessageFormat.format("select * from user where phone=''{0}''", one.getPhone());
		String[][] result = db.select("user", sql);
		
		if (result == null) 
		{
			return false;
		}
		else
		{
			return true;
		}
		
	}
	
}
